﻿using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Model
{
    [Table("Product")]
    public class Product : BaseModel
    {
        public string Name { get; set; }

        public decimal Price { get; set; }

        public string Code { get; set; }

        public int? ProductTypeId { get; set; }

        public virtual ProductType ProductType { get; set; }

        [NotMapped]
        public string TypeValue
        {
            get
            {
                return ProductType.Name;
            }
        }
    }

    [NotMapped]
    public class SearchProduct : BaseModel
    {
        public string Name { get; set; }

        public decimal? Price { get; set; }

        public decimal? Discount { get; set; }

        public decimal? Total { get; set; }

        public string TotalValue { get; set; }

        public string Code { get; set; }

        public int? ProductTypeId { get; set; }

        public int? Quantity 
        { 
            get
            {
                int value = 0;
                if(!string.IsNullOrEmpty(QuantityValue) && int.TryParse(QuantityValue, out value))
                {
                    return value;
                }

                return null;
            }
        }

        public string QuantityValue { get; set; }

        public string TypeValue
        {
            get;
            set;

        }

        public decimal? ActualPrice { get; set; }


    }
}
